package org.gap.service;

import java.util.Calendar;
import java.util.List;
import java.util.Set;

import org.gap.domain.Tiers;
import org.gap.domain.TiersModif;
import org.gap.domain.Utilisateurs;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/GAP_v2-security-context.xml",
		"file:./resources/GAP_v2-service-context.xml",
		"file:./resources/GAP_v2-dao-context.xml",
		"file:./resources/GAP_v2-web-context.xml" })
@Transactional
public class TiersModifServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected TiersModifService service;

	/**
	 * Instantiates a new TiersModifServiceTest.
	 *
	 */
	public TiersModifServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	 * Save an existing TiersModif entity
	 * 
	 */
	@Test
	public void saveTiersModif() {
		// TODO: JUnit - Populate test inputs for operation: saveTiersModif 
		TiersModif tiersmodif = new org.gap.domain.TiersModif();
		service.saveTiersModif(tiersmodif);
	}

	/**
	 * Operation Unit Test
	 * Save an existing Tiers entity
	 * 
	 */
	@Test
	public void saveTiersModifTiers() {
		// TODO: JUnit - Populate test inputs for operation: saveTiersModifTiers 
		Integer tmoTiers = 0;
		String tmoNomChampModif = null;
		Calendar tmoDateModification = null;
		Tiers related_tiers = new org.gap.domain.Tiers();
		TiersModif response = null;
		response = service.saveTiersModifTiers(tmoTiers, tmoNomChampModif, tmoDateModification, related_tiers);
		// TODO: JUnit - Add assertions to test outputs of operation: saveTiersModifTiers
	}

	/**
	 * Operation Unit Test
	 * Save an existing Utilisateurs entity
	 * 
	 */
	@Test
	public void saveTiersModifUtilisateurs() {
		// TODO: JUnit - Populate test inputs for operation: saveTiersModifUtilisateurs 
		Integer tmoTiers_1 = 0;
		String tmoNomChampModif_1 = null;
		Calendar tmoDateModification_1 = null;
		Utilisateurs related_utilisateurs = new org.gap.domain.Utilisateurs();
		TiersModif response = null;
		response = service.saveTiersModifUtilisateurs(tmoTiers_1, tmoNomChampModif_1, tmoDateModification_1, related_utilisateurs);
		// TODO: JUnit - Add assertions to test outputs of operation: saveTiersModifUtilisateurs
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Tiers entity
	 * 
	 */
	@Test
	public void deleteTiersModifTiers() {
		// TODO: JUnit - Populate test inputs for operation: deleteTiersModifTiers 
		Integer tiersmodif_tmoTiers = 0;
		String tiersmodif_tmoNomChampModif = null;
		Calendar tiersmodif_tmoDateModification = null;
		Integer related_tiers_tieTiers = 0;
		TiersModif response = null;
		response = service.deleteTiersModifTiers(tiersmodif_tmoTiers, tiersmodif_tmoNomChampModif, tiersmodif_tmoDateModification, related_tiers_tieTiers);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteTiersModifTiers
	}

	/**
	 * Operation Unit Test
	 * Return all TiersModif entity
	 * 
	 */
	@Test
	public void findAllTiersModifs() {
		// TODO: JUnit - Populate test inputs for operation: findAllTiersModifs 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<TiersModif> response = null;
		response = service.findAllTiersModifs(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllTiersModifs
	}

	/**
	 * Operation Unit Test
	 * Load an existing TiersModif entity
	 * 
	 */
	@Test
	public void loadTiersModifs() {
		Set<TiersModif> response = null;
		response = service.loadTiersModifs();
		// TODO: JUnit - Add assertions to test outputs of operation: loadTiersModifs
	}

	/**
	 * Operation Unit Test
	 * Delete an existing TiersModif entity
	 * 
	 */
	@Test
	public void deleteTiersModif() {
		// TODO: JUnit - Populate test inputs for operation: deleteTiersModif 
		TiersModif tiersmodif_1 = new org.gap.domain.TiersModif();
		service.deleteTiersModif(tiersmodif_1);
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Utilisateurs entity
	 * 
	 */
	@Test
	public void deleteTiersModifUtilisateurs() {
		// TODO: JUnit - Populate test inputs for operation: deleteTiersModifUtilisateurs 
		Integer tiersmodif_tmoTiers_1 = 0;
		String tiersmodif_tmoNomChampModif_1 = null;
		Calendar tiersmodif_tmoDateModification_1 = null;
		String related_utilisateurs_usrUser = null;
		TiersModif response = null;
		response = service.deleteTiersModifUtilisateurs(tiersmodif_tmoTiers_1, tiersmodif_tmoNomChampModif_1, tiersmodif_tmoDateModification_1, related_utilisateurs_usrUser);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteTiersModifUtilisateurs
	}

	/**
	 * Operation Unit Test
	 * Return a count of all TiersModif entity
	 * 
	 */
	@Test
	public void countTiersModifs() {
		Integer response = null;
		response = service.countTiersModifs();
		// TODO: JUnit - Add assertions to test outputs of operation: countTiersModifs
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findTiersModifByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findTiersModifByPrimaryKey 
		Integer tmoTiers_2 = 0;
		String tmoNomChampModif_2 = null;
		Calendar tmoDateModification_2 = null;
		TiersModif response = null;
		response = service.findTiersModifByPrimaryKey(tmoTiers_2, tmoNomChampModif_2, tmoDateModification_2);
		// TODO: JUnit - Add assertions to test outputs of operation: findTiersModifByPrimaryKey
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
